package com.qys.livesMall.anchor.model.entity;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * 主播封禁表
 * </p>
 *
 * @author wzy
 * @since 2023-06-26
 */
@Getter
@Setter
@TableName("h2_anchor_lives_room_ban")
@Schema(name = "AnchorLivesRoomBan", description = "主播封禁表")
public class AnchorLivesRoomBan implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "直播间封禁Id")
    @TableId(value = "id")
    private Long id;

    @Schema(description = "直播间id")
    private Long livesRoomId;

    @Schema(description = "主播id")
    private Long anchorId;

    @Schema(description = "主播名")
    private String anchorName;

    @Schema(description = "封禁天数（-1：永封）")
    private Integer banDay;

    @Schema(description = "期望解封日期（当前时间之后）")
    private LocalDate unbanDate;

    @Schema(description = "实际解封日期（当前时间之后）")
    private LocalDate realUnbanDate;

    @Schema(description = "封禁备注（不超过255字符）")
    private String limitRemark;

    @Schema(description = "是否有效（0：有效  1：失效）")
    private Byte active;

    @Schema(description = "操作人")
    private String banBy;

    @Schema(description = "封禁时间")
    private LocalDateTime banTime;

    public void initBanDate(Integer banDay) {
        this.banDay = banDay;
        if (banDay > 0) {
            this.unbanDate = LocalDate.now().plusDays(banDay + 1);
        } else {
            this.unbanDate = null;
        }
    }
}
